package com.jsoft.jsofted.sys.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.diboot.core.binding.annotation.BindField;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsNotNull;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.jsoft.jsofted.framework.entity.OfTenantEntity;
import com.jsoft.jsofted.framework.entity.TreeEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;

/**
 * 机构信息表：机构包括【公司、部门、人员组】等
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Table("sys_org")
@TableName("sys_org")
public class OrgEntity extends OfTenantEntity implements TreeEntity {

    @Column(length = 64)
    @IsNotNull
    protected String name;

    @Column(length = 256)
    protected String fullName;

    @Column
    protected Long parentId;

    @TableField(exist = false)
    @BindField(entity = OrgEntity.class, field = "name", condition = "parent_id=id")
    protected String parentName;

    @TableField(exist = false)
    @BindField(entity = OrgEntity.class, field = "full_name", condition = "parent_id=id")
    protected String parentFullName;

    /**
     * gov——政府机关，corp——公司，dept——部门，group——分组
     */
    @Column(length = 8)
    @IsNotNull
    protected String type;

    @Column(length = 20, decimalLength = 6)
    @IsNotNull
    protected BigDecimal sortValue;

    @Column(length = 256)
    protected String address;
}
